package com.test.controller;


import com.test.pojo.TbUser;
import com.test.service.TbUserService;
import com.test.utils.Response;
import com.test.utils.ResponseApi;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.security.SecureRandom;
import java.sql.Wrapper;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author yanglijun
 * @since 2020-12-12
 */
@RestController
@RequestMapping("/tb-user")
public class TbUserController {
    @Resource
    private TbUserService tbUserService;


    @RequestMapping("/test")
    public List<TbUser> test(){
        System.out.println("进来了/test！！！！！！！");
        return tbUserService.list();
    }

    @PostMapping("/login")
   public Response<String> login(@RequestBody TbUser tbUser){
        System.out.println(tbUser);
        String token = tbUserService.login(tbUser);
        ResponseApi<String> responseApi=new ResponseApi<>();
        if (token!=null) {
            System.out.println(token);
            return responseApi.setSuccess(token);
        }

        return responseApi.setError();

   }


}

